<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 *      [PinTuXiu] (C)2001-2099 ONightjar.com Pintuxiu.com.
 *      This is NOT a freeware, use is subject to license terms
 */
class setting_api{
	
	public function getCacheTime(){
		$settingdb = load_db('setting');
		return $settingdb->getSettings('cache_time');
	}

	public function getGlobalSetting(){
		$settingdb = load_db('setting');
		return $settingdb->getSettings('global');
	}

	public function getMessageSetting(){
		$settingdb = load_db('setting');
		return $settingdb->getSettings('message');
	}

	public function getStyleSetting(){
		$settingdb = load_db('setting');
		return $settingdb->getSettings('ui_styles');
	}
	
	public function getVcodeSetting(){
		$settingdb = load_db('setting');
		return $settingdb->getSettings('vcode');
	}
	
	public function getUploadSetting(){
		$settingdb = load_db('setting');
		return $settingdb->getSettings('upload');
	}

	public function getSetting($key){
		$settingdb = load_db('setting');
		return $settingdb->getSettings($key);
	}
	public function updateSetting($key,$data){
		$settingdb = load_db('setting');
		return $settingdb->set_value($key,$data);
	}
	
	public function getSmileByid($id){
		$smiledb = load_db('setting/smile');
		return $smiledb->findBy('smile_id',$id);
	}
	
	public function getSmiles($page,$pagesize){
		$smiledb = load_db('setting/smile');
		return $smiledb->search($page,$pagesize);
	}
	
	public function getSmilesWithCode(){
		$smiledb = load_db('setting/smile');
		return $smiledb->getSmilies();
	}
	
	public function deleteSmileByid($id){
		$smiledb = load_db('setting/smile');
		$result = $smiledb->delete(array('smile_id'=>$id));
		if($result) $smiledb->updateSmiliesCache();
		return $result;
	}
	
	public function addsmile($data){
		$smiledb = load_db('setting/smile');
		$result = $smiledb->create($data);
		if($result) $smiledb->updateSmiliesCache();
		return $result;
	}

	public function updateSmileByid($id,$update){
		$smiledb = load_db('setting/smile');
		$result = $smiledb->update(array('smile_id'=>$id),$update);
		if($result) $smiledb->updateSmiliesCache();
		return $result;
	}
}
